<template>
	<view class="customer-service">
		<!-- 顶部导航栏 -->
		<view class="nav-bar">
			<text class="back-icon" @click="goBack">‹</text>
			<text class="page-title">杂货铺</text>
			<view class="nav-right">
				<text class="nav-icon">⋯</text>
				<text class="nav-icon">−</text>
				<text class="nav-icon">◎</text>
			</view>
		</view>

		<!-- 聊天内容区域 -->
		<view class="chat-content">
			<!-- 这里可以添加聊天消息 -->
		</view>

		<!-- 底部产品卡片和输入区域 -->
		<view class="bottom-section">
			<!-- 产品卡片 -->
			<view class="product-card">
				<image class="product-image" src="/static/img/分类.png" mode="aspectFill"></image>
				<view class="product-info">
					<text class="product-name">佳能 EOS R5 全画幅 专业微单相机 R5 单机机身 24-105 套机 2222</text>
					<text class="product-price">¥3,111.00</text>
				</view>
				<text class="close-btn" @click="closeProductCard">×</text>
				<button class="send-product-btn" @click="sendProduct">发送商品</button>
			</view>

			<!-- 消息输入区域 -->
			<view class="input-section">
				<input class="message-input" placeholder="用一句简短的话描述您的问题" v-model="messageText" />
				<button class="send-btn" @click="sendMessage">发送</button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				messageText: ''
			}
		},
		methods: {
			goBack() {
				uni.navigateBack()
			},
			closeProductCard() {
				// TODO: 关闭产品卡片
				uni.showToast({
					title: '关闭产品卡片',
					icon: 'none'
				})
			},
			sendProduct() {
				// TODO: 发送产品信息
				uni.showToast({
					title: '发送商品成功',
					icon: 'success'
				})
			},
			sendMessage() {
				if (!this.messageText.trim()) {
					uni.showToast({
						title: '请输入消息内容',
						icon: 'none'
					})
					return
				}
				
				// TODO: 发送消息到服务器
				uni.showToast({
					title: '消息发送成功',
					icon: 'success'
				})
				this.messageText = ''
			}
		}
	}
</script>

<style scoped>
	.customer-service {
		background: #fff;
		min-height: 100vh;
		display: flex;
		flex-direction: column;
	}

	/* 顶部导航栏 */
	.nav-bar {
		background: #fff;
		height: 44px;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 15px;
		border-bottom: 1px solid #f0f0f0;
	}

	.back-icon {
		font-size: 20px;
		color: #333;
	}

	.page-title {
		font-size: 16px;
		color: #333;
		font-weight: bold;
	}

	.nav-right {
		display: flex;
		gap: 10px;
	}

	.nav-icon {
		font-size: 16px;
		color: #333;
	}

	/* 聊天内容区域 */
	.chat-content {
		flex: 1;
		background: #f5f5f5;
		/* 可以添加聊天消息的样式 */
	}

	/* 底部区域 */
	.bottom-section {
		background: #fff;
		border-top: 1px solid #f0f0f0;
	}

	/* 产品卡片 */
	.product-card {
		position: relative;
		display: flex;
		align-items: center;
		padding: 10px 15px;
		border-bottom: 1px solid #f0f0f0;
	}

	.product-image {
		width: 60px;
		height: 60px;
		border-radius: 5px;
		margin-right: 10px;
		background: #f0f0f0;
	}

	.product-info {
		flex: 1;
	}

	.product-name {
		font-size: 14px;
		color: #333;
		line-height: 1.3;
		margin-bottom: 5px;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
	}

	.product-price {
		font-size: 14px;
		color: #ff4444;
		font-weight: bold;
	}

	.close-btn {
		position: absolute;
		top: 10px;
		right: 10px;
		font-size: 18px;
		color: #999;
		width: 20px;
		height: 20px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.send-product-btn {
		position: absolute;
		bottom: 10px;
		right: 10px;
		background: #ff4444;
		color: #fff;
		border: none;
		padding: 5px 10px;
		border-radius: 3px;
		font-size: 12px;
	}

	/* 输入区域 */
	.input-section {
		display: flex;
		align-items: center;
		padding: 10px 15px;
		gap: 10px;
	}

	.message-input {
		flex: 1;
		height: 36px;
		background: #f5f5f5;
		border: none;
		border-radius: 18px;
		padding: 0 15px;
		font-size: 14px;
		color: #333;
	}

	.message-input::placeholder {
		color: #999;
	}

	.send-btn {
		background: #ff4444;
		color: #fff;
		border: none;
		padding: 8px 15px;
		border-radius: 5px;
		font-size: 14px;
	}
</style>
